package com.barneyx.mshinfoplatform.util.admin

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
import com.baomidou.mybatisplus.core.toolkit.support.SFunction
import com.barneyx.mshinfoplatform.entity.admin.AreaAdminUserMapEntity
import com.barneyx.mshinfoplatform.entity.area.AreaEntity
import com.barneyx.mshinfoplatform.exception.AdminUserException
import com.barneyx.mshinfoplatform.service.admin.*
import com.barneyx.mshinfoplatform.service.area.IAreaEntityService
import com.barneyx.mshinfoplatform.util.EventUtil
import com.barneyx.mshinfoplatform.util.RedisUtil
import lombok.extern.slf4j.Slf4j
import org.springframework.stereotype.Component
import javax.annotation.Resource


@Component
@Slf4j
sealed class AdminUserUtil {

    @Resource
    lateinit var adminUserService: IAdminUserEntityService

    @Resource
    lateinit var adminUserRoleMapService: IAdminUserRoleMapEntityService

    @Resource
    lateinit var adminRoleService: IAdminRoleEntityService

    @Resource
    lateinit var adminRolePermissionMapService: IAdminRolePermissionMapEntityService

    @Resource
    lateinit var adminPermissionService: IAdminPermissionEntityService

    @Resource
    lateinit var areaAdminUserMapService: IAreaAdminUserMapEntityService

    @Resource
    lateinit var areaService: IAreaEntityService

    @Resource
    lateinit var redisUtil: RedisUtil

    @Resource
    lateinit var eventUtil: EventUtil

    /**
     * 根据当前用户编号获取当前用户所管辖的区域列表
     *
     * @param adminUserId
     * @return
     * @throws AdminUserException
     */
   /* fun getAreaAdminListByAdminUserId(adminUserId: String): List<AreaEntity>? =>
    areaAdminUserMapService.list(LambdaQueryWrapper<AreaAdminUserMapEntity>()
                .eq(AreaAdminUserMapEntity::getAreaId, adminUserId)).let {list->
            list.map { AreaAdminUserMapEntity::getAreaId }.toList().let {
                areaService.list(LambdaQueryWrapper<AreaEntity>().`in`(AreaEntity::getAreaId, it))?.let {
                    it.forEach { areaEntity ->
                        if (!areaEntity.areaParentId.equals("0")) {
                            areaEntity.setParentAreaInfo(areaService.getById(areaEntity.areaParentId))
                        }
                    }
                }
            }
        }*/
}